package com.b511.swpu.cementbackend.repository;

import com.b511.swpu.cementbackend.entity.SYSM_DataDict;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface SYSM_DataDictRepository extends JpaRepository<SYSM_DataDict, Long> , JpaSpecificationExecutor<SYSM_DataDict> {
    @Query("select d from SYSM_DataDict d where d.DICTCODE like ?1% and length(d.DICTCODE)-2=?2")
    List<SYSM_DataDict> selectCodeLike(String code,int len);

    @Query(value = "select NAME from SYSM_DataDict where DICTCODE like ?1% and length(DICTCODE)-2=?2",nativeQuery = true)
    List<String> findByDICTCODEChild(String code, int len);

    @Query("select d from SYSM_DataDict d where d.NAME =?1")
    SYSM_DataDict findCodeByNAME(String label);

    //查询井型：直井\定向井\大位移井
    @Query(value = "select NAME from SYSM_DataDict where DICTCODE like '0003__' ",nativeQuery = true)
    List<String> findWellType();

    //查询井别：直井\定向井\大位移井
    @Query(value = "select NAME from SYSM_DataDict where DICTCODE like '0004__' ",nativeQuery = true)
    List<String> findWellSpacing();
}
